<template>
	<view class="box">
		<base-form v-model="formModel" :labelWidth="130" :formList="formList" :btnMessage="btnMessage" @submit="submit">
			<Autograph @fj="fileUrls" slot="sin" style="height: 500rpx; width: 100%"></Autograph>
		</base-form>
	</view>
</template>

<script>
	import Autograph from "@/pages/autograph/autograph";
	import {
		getTickListById,
		add
	} from "@/api/gasTest.js";
	export default {
		components: {
			Autograph,
		},
		data() {
			return {
				formModel: {},
				fxrqz: "",
				params: {},
				formList: [{
						type: "datetime",
						label: "取样分析时间",
						mode: "datetime",
						model: "qyfxsj",
						placeholder:"请选择取样分析时间",
						borderBottom: true,
						show: false,
					},
					{
						type: "input",
						label: "代表性气体",
						model: "dbxqt",
							placeholder:"请输入代表性气体",
						borderBottom: true,
					},
					{
						type: "input",
						label: "取样分析部位",
						placeholder:"请输入分析部位",
						model: "qyfxbw",
						borderBottom: true,
					},
					{
						type: "input",
						label: "可燃气体LEL%",
						model: "krqt",
						placeholder:"请输入可燃气体",
						borderBottom: true,
					},
					{
						type: "input",
						label: "有毒气体ppm",
						model: "ydqt",
						placeholder:"请输入有毒气体",
						borderBottom: true,
					},
					{
						type: "input",
						label: "含氧量",
						model: "yhl",
						placeholder:"请输入氧含量",
						borderBottom: true,
					},
					{
						type: "userPicker",
						label: "分析人",
						model: "fxr",
						placeholder:"请选择分析人",
						borderBottom: true,
					},
					{
						type: "slot",
						slotName: "sin",
						label: "分析人",
						model: "name",
						borderBottom: true,
					},
				],
				btnMessage: {
					cancels: "返回",
					submit: "提交",
				},
			};
		},
		methods: {
			submit() {
				if (!this.fxrqz) {
					uni.showToast({
						icon: "none",
						title: "请先保存签名！",
					});
					return;
				}
				let data = {
					...this.formModel,
					fxrqz: this.fxrqz,
					glzypid:this.params.id
				};
				add(data).then((res) => {
					uni.showToast({
						icon: "none",
						title: "提交成功！",
					});
					uni.navigateTo({
						url: "../information/information?params=" +
							encodeURIComponent(JSON.stringify(this.params)),
					});
				});
			},
			getlist() {
				getTickListById(this.params.id).then((r) => {
					console.log(r);
				})
			},
			fileUrls(val) {
				this.fxrqz = val;
			},
		},
		onLoad(options) {
			this.params = JSON.parse(decodeURIComponent(options.params));
			this.getlist()
		},
	};
</script>

<style lang="scss" scoped>
	.box {
		width: 100%;
		box-sizing: border-box;
		height: calc(100vh - 88rpx);
		background: #fff;
		padding: 20rpx;
	}

	::v-deep .u-form-item__body__right__content__slot {
		flex-direction: column !important;
	}
</style>
